<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>AutoHotkey FAQ</title>
<link href="static/theme.css" rel="stylesheet" type="text/css" />
<script src="static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Frequently Asked Questions (FAQ)</h1>

<p>If your question is not in the list below, check the community-driven <a href="http://www.autohotkey.net/~faqbot/faq.html">FAQ on autoHotkey.net</a>.</p>

<h3>Language Syntax</h3>
<ul>
  <li><a href="#quotes">When are quotation marks used with commands and their parameters?</a></li>
  <li><a href="#percent">When exactly are variable names enclosed in percent signs?</a></li>
  <li><a href="#esc">When should percent signs and commas be escaped?</a></li>
</ul>
<h3>Common Tasks</h3>
<ul>
  <li><a href="#Download">Where can I find the official build, or older releases?</a></li>
  <li><a href="#autoexec">Why do some lines in my script never execute?</a></li>
  <li><a href="#vista">Why does my script run fine in XP but not in Vista or Windows 7 or 8?</a></li>
  <li><a href="#DefaultScript">I can't edit my script via tray icon because it won't start due to an error. Can I find my script somewhere else?</a></li>
  <li><a href="#Debug">How can I find and fix errors in my code?</a></li>
  <li><a href="#USB">Can I run AHK from a USB drive?</a></li>
  <li><a href="#run">Why is the Run command unable to launch my game or program?</a></li>
  <li><a href="#output">How can the output of a command line operation be retrieved?</a></li>
  <li><a href="#close">How can a script close, pause, or suspend other script(s)?</a></li>
  <li><a href="#repeat">How can a repeating action be stopped without exiting the script?</a></li>
  <li><a href="#perf">How can performance be improved for games or at other times when the CPU is under heavy load?</a></li>
  <li><a href="#help">How can context sensitive help for AutoHotkey commands be used in any editor?</a></li>
  <li><a href="#load">How to detect when a web page is finished loading?</a></li>
  <li><a href="#time">How can dates and times be compared or manipulated?</a></li>
  <li><a href="#SendDate">How can I send the current Date and/or Time?</a></li>
  <li><a href="#ControlSend">How can I send text to a window which isn't active or isn't visible?</a></li>
  <li><a href="#games">Why don't Hotstrings, Send, and MouseClick work in certain games?</a></li>
  <li><a href="#winamp">How can Winamp be controlled even when it isn't active?</a></li>
  <li><a href="#msgbox">How can MsgBox's button names be changed?</a></li>
  <li><a href="#DefaultEditor">How can I change the default editor, which is accessible via context menu or tray icon?</a></li>
  <li><a href="#GuiSubmit">How can I save the contents of my GUI associated variables?</a></li>
  <li><a href="#GDIPlus">Can I draw something with AHK?</a></li>
  <li><a href="#WinWaitAction">How can I start an action when a window appears, closes or becomes [in]active?</a></li>
  <li><a href="#Virus">My antivirus program flagged AHK as malware. Does it really contain a virus?</a></li>
</ul>
<h3>Hotkeys, Hotstrings, and Remapping</h3>
<ul>
  <li><a href="#Startup">How do I put my hotkeys and hotstrings into effect automatically every time I start my PC?</a></li>
  <li><a href="#HotMouse">I'm having trouble getting my mouse buttons working as hotkeys. Any advice?</a></li>
  <li><a href="#HotSymb">How can tab and space be defined as hotkeys?</a></li>
  <li><a href="#Remap">How can keys or mouse buttons be remapped so that they become different keys?</a></li>
  <li><a href="#DoublePress">How do I detect the double press of a key or button?</a></li>
  <li><a href="#HotContext">How can a hotkey or hotstring be made exclusive to certain program(s)? In other words, I want a certain key to act as it normally does except when a specific window is active.</a></li>
  <li><a href="#HotPrefix">How can a prefix key be made to perform its native function rather than doing nothing?</a></li>
  <li><a href="#HotOverride">How can the built-in Windows shortcut keys, such as Win+U (Utility Manager) and Win+R (Run), be changed or disabled?</a></li>
  <li><a href="#HotRegEx">Can I use wildcards or regular expressions in Hotstrings?</a></li>
  <li><a href="#SpecialKey">How can I use a hotkey that is not in my keyboard layout?</a></li>
  <li><a href="#HotZero">My keypad has a special 000 key. Is it possible to turn it into a hotkey?</a></li>
</ul>
<h2>Language Syntax</h2>
<h3 id="quotes">When are quotation marks used with commands and their parameters?</h3>
<p>Double quotes (&quot;) have special meaning only within <a href="Variables.htm#Expressions">expressions</a>. In all other places, they are treated literally as if they were normal characters. However, when a script launches a program or document, the operating system usually requires quotes around any command-line parameter that contains spaces, such as in this example: <code>Run, Notepad.exe &quot;C:\My Documents\Address List.txt&quot;</code>.</p>
<h3 id="percent">When exactly are variable names enclosed in percent signs?</h3>
<p>Variable names are always enclosed in percent signs except in cases illustrated in <strong>bold</strong> below:</p>
<p>1) In parameters that are input or output variables: <code><a href="commands/StringLen.htm">StringLen</a>, <strong>OutputVar</strong>, <strong>InputVar</strong></code><br>
  2) On the left side of an assignment: <code><strong>Var</strong> = 123abc</code><br>
  3) On the left side of <a href="commands/IfEqual.htm">traditional (non-expression) if-statements</a>: <code>If <strong>Var1</strong> &lt; %Var2%</code><br>
4) Everywhere in <a href="Variables.htm#Expressions">expressions</a>. For example:</p>
<pre>If (<strong>Var1</strong> &lt;&gt; <strong>Var2</strong>)
    <strong>Var1 <a href="commands/SetExpression.htm">:=</a> Var2</strong> + 100</pre>
<h3 id="esc">When should percent signs and commas be <a href="commands/_EscapeChar.htm">escaped</a>?</h3>
<p>Literal percent signs must be <a href="commands/_EscapeChar.htm">escaped</a> by preceding them with an accent/backtick. For example: <code>MsgBox The current percentage is 25`%.</code> Literal commas must also be escaped (<code>`,</code>) except when used in <a href="commands/MsgBox.htm">MsgBox</a> or the last parameter of any command (in which case the accent is permitted but not necessary).</p>
<p> When commas or percent signs are enclosed in quotes within an <a href="Variables.htm#Expressions">expression</a>, the accent is permitted but not necessary. For example: <code>Var := &quot;15%&quot;</code>.</p>
<h2>Common Tasks</h2>
<h3 id="Download">Where can I find the official build, or older releases?</h3>
<p>See <a href="http://ahkscript.org/download/">download page of AutoHotkey</a>.</p>
<h3 id="autoexec">Why do some lines in my script never execute?</h3>
<p>Any lines you want to execute immediately when the script starts should appear at the top of the script, prior to the first <a href="Hotkeys.htm">hotkey</a>, <a href="Hotstrings.htm">hotstring</a>, or <a href="commands/Return.htm">Return</a>. For details, see <a href="Scripts.htm#auto">auto-execute section</a>.</p>
<p>Also, a <a href="Hotkeys.htm">hotkey</a> that executes more than one line must list its first line <em>beneath</em> the hotkey, not on the same line. For example:</p>
<pre>#space::  <em>; Win+Spacebar</em>
Run Notepad
WinWaitActive Untitled - Notepad
WinMaximize
return</pre>
<h3 id="vista">Why does my script run fine in XP but not in Vista or Windows 7 or 8?</h3>
<p>Since you've switched operating systems, it is likely that something else may have also changed which could be affecting your script. For instance, if you've got a new computer, it might differ in some way to the old computer. If you've also updated to a newer version of AutoHotkey, find out which version you had before and then check the <a href="AHKL_ChangeLog.htm">changelog</a> and <a href="Compat.htm">compatibility notes</a>.</p>
<p>A common problem when moving from XP to Vista or a later version of Windows is that programs which are "elevated" (run as administrator) block hotkeys or refuse to be automated. There are at least three workarounds:</p>
<ul>
  <li>Modify AutoHotkey.exe to enable interaction with administrative programs. This has some drawbacks. For more information see <a href="http://www.autohotkey.com/board/topic/70449-enable-interaction-with-administrative-programs/">http://www.autohotkey.com/board/topic/70449-enable-interaction-with-administrative-programs/</a></li>
  <li>Run the script <a href="Variables.htm#IsAdmin">as administrator</a>. Note that this also causes any programs launched by the script to run as administrator.</li>
  <li>Disable <a href="http://windows.microsoft.com/en-US/windows7/What-is-User-Account-Control">User Account Control</a> (not recommended); in Windows 8 and later you may also have to disable the security setting &quot;Run all administrators in Admin Approval Mode&quot; (also not recommended).</li>
</ul>
<p><a href="commands/SoundGet.htm">SoundGet</a>, <a href="commands/SoundSet.htm">SoundSet</a>, <a href="commands/SoundGetWaveVolume.htm">SoundGetWaveVolume</a> and <a href="commands/SoundSetWaveVolume.htm">SoundSetWaveVolume</a> behave differently on Vista and later than on earlier versions of Windows. In particular, device numbers are different and some components may be unavailable. Behaviour depends on the audio drivers, which are necessarily different to the ones used on XP. The <a href="commands/SoundSet.htm#Ex">soundcard analysis script</a> can be used to find the correct device numbers.</p>
<h3 id="DefaultScript">I can't edit my script via tray icon because it won't start due to an error. What do I do?</h3>
<p>You need to fix the error in your script before you can get your tray icon back. But first, you need to find the script file.</p>
<p>Look for AutoHotkey.ahk in the following directories:</p>
<ul>
  <li>Your <em>Documents</em> (or <em>My Documents</em>) folder.</li>
  <li>The directory where you installed AutoHotkey, usually C:\Program Files\AutoHotkey. If you are using AutoHotkey without having installed it, look in the directory which contains AutoHotkey.exe.</li>
</ul>
<p>If you are running another AutoHotkey executable directly, the name of the script depends on the executable. For example, if you are running AutoHotkeyU32.exe, look for AutoHotkeyU32.ahk. Note that depending on your system settings the ".ahk" part may be hidden, but the file should have an icon like <img src="static/ahkfile16.png" alt="[H]"></p>
<p>You can usually edit a script file by right clicking it and selecting <em>Edit Script</em>. If that doesn't work, you can open the file in Notepad or another editor.</p>
<p>If you launch AutoHotkey from the Start menu or by running AutoHotkey.exe directly (without command line parameters), it will look for a script in one of the locations shown above. Alternatively, you can create a script file (something.ahk) anywhere you like, and run the script file instead of running AutoHotkey.</p>
<p>See also <a href="Scripts.htm#defaultfile">Command Line Parameter &quot;Script Filename&quot;</a> and <a href="Scripts.htm#port">Portability of AutoHotkey.exe</a>.</p>
<h3 id="Debug">How can I find and fix errors in my code?</h3>
<p>For simple scripts, see <a href="Scripts.htm#debug">Debugging a Script</a>. To show contents of a variable, use <a href="commands/MsgBox.htm">MsgBox</a> or <a href="commands/ToolTip.htm">ToolTip</a>. For complex scripts, see <a href="Scripts.htm#idebug">Interactive Debugging</a>.</p>
<h3 id="USB">Can I run AHK from a USB drive?</h3>
<p>See <a href="Scripts.htm#port">Portability of AutoHotkey.exe</a>. Note that if you use auto-included function libraries, AutoHotkey.exe and the Lib folder must be up one level from Ahk2Exe.exe (e.g. \AutoHotkey.exe vs \Compiler\Ahk2Exe.exe). Also note that Ahk2Exe saves settings to the following registry key: <code>HKEY_CURRENT_USER\Software\AutoHotkey\Ahk2ExeCommand</code>.</p>
<h3 id="run">Why is the <a href="commands/Run.htm">Run</a> command unable to launch my game or program?</h3>
<p>Some programs need to be started in their own directories (when in doubt, it is usually best to do so). For example:</p>
<pre>Run, %A_ProgramFiles%\Some Application\App.exe, %A_ProgramFiles%\Some Application</pre>
<h3 id="output">How can the output of a command line operation be retrieved?</h3>
<p>Testing shows that due to file caching, a temporary file can be very fast for relatively small outputs. In fact, if the file is deleted immediately after use, it often does not actually get written to disk. For example:</p>
<pre><a href="commands/Run.htm">RunWait</a> %comspec% /c dir &gt; C:\My Temp File.txt
FileRead, VarToContainContents, C:\My Temp File.txt
FileDelete, C:\My Temp File.txt</pre>
<p>To avoid using a temporary file (especially if the output is large), consider using <a href="http://www.autohotkey.com/forum/topic8606.html">CmdRet</a> or <a href="http://www.autohotkey.com/forum/topic16823.html">StdoutToVar</a>.</p>
<h3 id="close">How can a script close, pause, or suspend other script(s)?</h3>
<p>First, here is an example that closes another script:</p>
<pre>DetectHiddenWindows On  <em>; Allows a script's hidden main window to be detected.</em>
SetTitleMatchMode 2  <em>; Avoids the need to specify the full path of the file below.</em>
WinClose Script's File Name.ahk - AutoHotkey  <em>; Update this to reflect the script's name (case sensitive).</em></pre>
<p>To <a href="commands/Suspend.htm">suspend</a> or <a href="commands/Pause.htm">pause</a> another script, replace the last line above with one of these:</p>
<pre>PostMessage, 0x111, 65305,,, Script's File Name.ahk - AutoHotkey  <em>; Suspend.</em>
PostMessage, 0x111, 65306,,, Script's File Name.ahk - AutoHotkey  <em>; Pause.</em></pre>
<h3 id="repeat">How can a repeating action be stopped without exiting the script?</h3>
<p>To pause or resume the entire script at the press of a key, assign a hotkey to the <a href="commands/Pause.htm">Pause</a> command as in this example:</p>
<pre>^!p::Pause  <em>; Press Ctrl+Alt+P to pause. Press it again to resume.</em></pre>
<p>To stop an action that is repeating inside a <a href="commands/Loop.htm">Loop</a>, consider the following working example, which is a hotkey that both starts and stops its own repeating action. In other words, pressing the hotkey once will start the Loop. Pressing the same hotkey again will stop it.</p>
<pre>#MaxThreadsPerHotkey 3
<strong>#z::  <em>; Win+Z hotkey (change this hotkey to suit your preferences).</em></strong>
#MaxThreadsPerHotkey 1
if KeepWinZRunning  <em>; This means an underlying <a href="misc/Threads.htm">thread</a> is already running the loop below.</em>
{
    KeepWinZRunning := false  <em>; Signal that thread's loop to stop.</em>
    return  <em>; End this thread so that the one underneath will resume and see the change made by the line above.</em>
}
<em>; Otherwise:</em>
KeepWinZRunning := true
Loop
{
    <strong><em>; The next four lines are the action you want to repeat (update them to suit your preferences):</em></strong>
    ToolTip, Press Win-Z again to stop this from flashing.
    Sleep 1000
    ToolTip
    Sleep 1000
    <strong><em>; But leave the rest below unchanged.</em></strong>
    if not KeepWinZRunning  <em>; The user signaled the loop to stop by pressing Win-Z again.</em>
        break  <em>; Break out of this loop.</em>
}
KeepWinZRunning := false  <em>; Reset in preparation for the next press of this hotkey.</em>
return</pre>
<h3 id="perf">How can performance be improved for games or at other times when the CPU is under heavy load?</h3>
<p>If a script's <a href="Hotkeys.htm">Hotkeys</a>, <a href="commands/Click.htm">Clicks</a>, or <a href="commands/Send.htm">Sends</a> are noticeably slower than normal while the CPU is under heavy load, raising the script's process-priority may help. To do this, include the following line near the top of the script:</p>
<pre><a href="commands/Process.htm">Process</a>, Priority, , High</pre>
<h3 id="help">How can context sensitive help for AutoHotkey commands be used in any editor?</h3>
<p>Rajat created <a href="scripts/ContextSensitiveHelp.htm">this script</a>.</p>
<h3 id="load">How to detect when a web page is finished loading?</h3>
<p>With Internet Explorer, perhaps the most reliable method is to use DllCall and COM as demonstrated at <a href="http://www.autohotkey.com/forum/topic19256.html">www.autohotkey.com/forum/topic19256.html</a>. On a related note, the contents of the address bar and status bar can be retrieved as demonstrated at <a href="http://www.autohotkey.com/forum/topic19255.html">www.autohotkey.com/forum/topic19255.html</a>.</p>
<p><strong>Older, less reliable method:</strong> The technique in the following example will work with MS Internet Explorer for most pages. A similar technique might work in other browsers:</p>
<pre>Run, www.yahoo.com
MouseMove, 0, 0  <em>; Prevents the status bar from showing a mouse-hover link instead of &quot;Done&quot;.</em>
WinWait, Yahoo! - 
WinActivate 
<a href="commands/StatusBarWait.htm">StatusBarWait</a>, Done, 30
if ErrorLevel
   MsgBox The wait timed out or the window was closed. 
else 
   MsgBox The page is done loading.</pre>
<h3 id="time">How can dates and times be compared or manipulated?</h3>
<p>The <a href="commands/EnvAdd.htm">EnvAdd</a> command can add or subtract a quantity of days, hours, minutes, or seconds to a time-string that is in the <a href="commands/FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> format. The following example subtracts 7 days from the specified time: <code>EnvAdd, VarContainingTimestamp, -7, days</code>.</p>
<p>To determine the amount of time between two dates or times, see <a href="commands/EnvSub.htm">EnvSub</a>, which gives an example. Also, the built-in variable <a href="Variables.htm#Now">A_Now</a> contains the current local time. Finally, there are several built-in <a href="Variables.htm#date">date/time variables</a>, as well as the <a href="commands/FormatTime.htm">FormatTime</a> command to create a custom date/time string.</p>
<h3 id="SendDate">How can I send the current Date and/or Time?</h3>
<p>Use <a href="commands/FormatTime.htm">FormatTime</a> or <a href="Variables.htm#date">built-in variables for date and time</a>.</p>
<h3 id="ControlSend">How can I send text to a window which isn't active or isn't visible?</h3>
<p>Use <a href="commands/ControlSend.htm">ControlSend</a>.</p>
<h3 id="games">Why do <a href="Hotstrings.htm">Hotstrings</a>, <a href="commands/Send.htm">Send</a>, and <a href="commands/Click.htm">Click</a> have no effect in certain games?</h3>
<p>Not all games allow AHK to send keys and clicks or receive pixel colors.</p>
<p>But there are some alternatives, try all the solutions mentioned below. If all these fail, it may not be possible for AHK to work with your game. Sometimes games have a hack and cheat prevention measure, such as GameGuard and Hackshield. If they do, there is a high chance that AutoHotkey will not work with that game.</p>
<ul>
  <li>
  <p>Use SendPlay via the <a href="commands/Send.htm#SendPlay">SendPlay</a> command, <a href="commands/SendMode.htm">SendMode Play</a> and/or the <a href="Hotstrings.htm">hotstring option SP</a>.</p>
  <pre>SendPlay, abc</pre>
  <pre>SendMode, Play
Send, abc</pre>
  <pre>:SP:btw::by the way

<em>; or</em>

#Hotstring SP
::btw::by the way</pre>
  <p>Note: SendPlay may have no effect at all on Windows Vista or later if User Account Control is enabled, even if the script is running as an administrator.</p>
  </li>
  <li>
  <p>Increase <a href="commands/SetKeyDelay.htm">SetKeyDelay</a>. For example:</p>
  <pre>SetKeyDelay, 0, 50
SetKeyDelay, 0, 50, Play</pre>
  </li>
  <li>
  <p>Try <a href="commands/ControlSend.htm">ControlSend</a>, which might work in cases where the other Send modes fail:</p>
  <pre>ControlSend,, abc, game_title</pre>
  </li>
  <li>
  <p>Try the down and up event of a key with the various send methods:</p>
  <pre>Send {KEY down}{KEY up}</pre>
  </li>
  <li>
  <p>Try the down and up event of a key with a <a href="commands/ControlSend.htm">Sleep</a> between them:</p>
  <pre>Send {KEY down}
Sleep 10 <em>; try various milliseconds</em>
Send {KEY Up}</pre>
  </li>
</ul>
<h3 id="winamp">How can Winamp be controlled even when it isn't active?</h3>
<p>See <a href="misc/Winamp.htm">Automating Winamp</a>.</p>
<h3 id="msgbox">How can <a href="commands/MsgBox.htm">MsgBox</a>'s button names be changed?</h3>
<p>Here is an <a href="scripts/MsgBoxButtonNames.htm">example</a>.</p>
<h3 id="DefaultEditor">How can I change the default editor, which is accessible via context menu or tray icon?</h3>
<p>In the example section of <a href="commands/Edit.htm">Edit</a> you will find a script that allows you to change the default editor.</p>
<h3 id="GuiSubmit">How can I save the contents of my GUI associated variables?</h3>
<p>Use <a href="commands/Gui.htm#Submit">Gui Submit</a>. For Example:</p>
<pre>Gui, Add, Text,, Enter some Text and press Submit:
Gui, Add, Edit, vAssociatedVar
Gui, Add, Button,, Submit
Gui, Show
Return

ButtonSubmit:
Gui, Submit, NoHide
MsgBox, Content of the edit control: %AssociatedVar%
Return</pre>
<h3 id="GDIPlus">Can I draw something with AHK?</h3>
<p>See <a href="http://www.autohotkey.com/forum/topic32238.html">GDI+ standard library</a> by tic. It's also possible with some rudimentary methods using Gui, but in a limited way.</p>
<h3 id="WinWaitAction">How can I start an action when a window appears, closes or becomes [in]active?</h3>
<p>Use <a href="commands/WinWait.htm">WinWait</a>, <a href="commands/WinWaitClose.htm">WinWaitClose</a> or <a href="commands/WinWaitActive.htm">WinWait[Not]Active</a>. See the <a href="http://www.autohotkey.net/~faqbot/faq.html#window">community-driven FAQ</a> (windows section) for more possibilities.</p>
<h3 id="Virus">My antivirus program flagged AHK as malware. Does it really contain a virus?</h3>
<p>Of course not. Antivirus programs may incorrectly recognize AHK as malware (called false positive), when the script is compiled with a compressor like UPX (default in AHK 1.0, removed in AHK 1.1) or MPRESS (optional in AHK 1.1). Compressors can reduce the size of compiled scripts. If you don't necessarily need this for your compiled executable, you should avoid using a compressor to prevent false alarms from the AV program for you and potential other users.</p>
<h2>Hotkeys, Hotstrings, and Remapping</h2>
<h3 id="Startup">How do I put my hotkeys and hotstrings into effect automatically every time I start my PC?</h3>
<p>There is a folder in the Start Menu called Startup. If you put a shortcut to your script  in that folder, the script will launch automatically every time you start your PC. To create a shortcut:</p>
<ol>
  <li>Find the script file, select it, and press Control-C.</li>
  <li>Right-click the Start button (typically at the lower left corner of the screen) and choose &quot;Explore All Users&quot;.</li>
  <li>Navigate to the Startup folder inside the Programs folder.</li>
  <li>From the menu bar, choose <em>Edit -&gt; Paste Shortcut</em>. The shortcut to the script should now be in the Startup folder.</li>
</ol>
<h3 id="HotMouse">I'm having trouble getting my mouse buttons working as hotkeys. Any advice?</h3>
<p>The left and right mouse buttons should be assignable normally (for example, <code>#LButton::</code> is the Win+LeftButton hotkey). Similarly, the middle button and the turning of the <a href="KeyList.htm">mouse wheel</a> should be assignable normally except on mice whose drivers directly control those buttons.</p>
<p> The fourth button (XButton1) and the fifth button (XButton2) might be assignable if your mouse driver allows their clicks to be <a href="commands/KeyHistory.htm">seen</a> by the system. If they cannot be seen -- or if your mouse has more than five buttons that you want to use -- you can try configuring the software that came with the mouse (sometimes accessible in the Control Panel or Start Menu) to send a keystroke whenever you press one of these buttons. Such a keystroke can then be defined as a hotkey in a script. For example, if you configure the fourth button to send Control+F1, you can then indirectly configure that button as a hotkey by using <code>^F1::</code> in a script.</p>
<p>If you have a five-button mouse whose fourth and fifth buttons cannot be <a href="commands/KeyHistory.htm">seen</a>, you can try changing your mouse driver to the default driver included with the OS. This assumes there is such a driver for your particular mouse and that you can live without the features provided by your mouse's custom software.</p>
<h3 id="HotSymb">How can Tab and Space be defined as hotkeys?</h3>
<p>Use the names of the keys (Tab and Space) rather than their characters. For example, <code>#Space</code> is Win+Space and <code>^!Tab</code> is Control+Alt+Tab.</p>
<h3 id="Remap">How can keys or mouse buttons be remapped so that they become different keys?</h3>
<p>This is described on the <a href="misc/Remap.htm">remapping</a> page.</p>
<h3 id="DoublePress">How do I detect the double press of a key or button?</h3>
<p>Use <a href="Variables.htm#h">built-in variables for hotkeys</a> as follows:</p>
<pre>~Ctrl::
    if (A_ThisHotkey = A_PriorHotkey &amp;&amp; A_TimeSincePriorHotkey &lt; 200)
        MsgBox double-press
return</pre>
<h3 id="HotContext">How can a <a href="Hotkeys.htm">hotkey</a> or <a href="Hotstrings.htm">hotstring</a> be made exclusive to  certain program(s)? In other words, I want a certain key to act as it normally does except when a specific window is active.</h3>
<p>The preferred method is <a href="commands/_IfWinActive.htm">#IfWinActive</a>. For example:</p>
<pre>#IfWinActive, ahk_class Notepad
^a::MsgBox You pressed Control-A while Notepad is active.
</pre>
<h3 id="HotPrefix">How can  a prefix key be made to perform its native function rather than doing nothing?</h3>
<p>Consider the following example, which makes Numpad0 into a prefix key:</p>
<pre>Numpad0 &amp; Numpad1::MsgBox, You pressed Numpad1 while holding down Numpad0.</pre>
<p>Now, to make Numpad0 send a real Numpad0 keystroke whenever it wasn't used to launch a hotkey such as the above, add the following hotkey:</p>
<pre> $Numpad0::Send, {Numpad0}</pre>
<p>The $ prefix is needed to prevent a warning dialog about an infinite loop (since the hotkey &quot;sends itself&quot;). In addition, the above action occurs at the time the key is <strong>released.</strong></p>
<h3 id="HotOverride">How can the built-in Windows shortcut keys, such as Win+U (Utility Manager) and Win+R (Run), be changed or disabled?</h3>
<p>Here are some <a href="misc/Override.htm">examples</a>.</p>
<h3 id="HotRegex">Can I use wildcards or regular expressions in Hotstrings?</h3>
<p>Use the <a href="https://github.com/polyethene/AutoHotkey-Scripts/blob/master/Hotstrings.ahk">script</a> by polyethene (examples are included).</p>
<h3 id="SpecialKey">How can I use a hotkey that is not in my keyboard layout?</h3>
<p>See <a href="KeyList.htm#SpecialKeys">Special Keys</a>.</p>
<h3 id="HotZero">My keypad has a special 000 key. Is it possible to turn it into a hotkey?</h3>
<p>Yes. This  <a href="scripts/Numpad000.htm">example script</a> makes the 000 key into an equals key. You can change the action by replacing the <code>Send, =</code> line with line(s) of your choice.</p>
</body>
</html>
